package jscinttools.scint;

import jscinttools.utilities.jhplotutilities.FigureParametersJHPlot;
import jscinttools.utilities.jhplotutilities.HPlotJaUtil;

//import jhplot.DrawOptions;
import jhplot.H1D;
import jhplot.F1D;
import jhplot.HPlotJa;
import jhplot.jadraw.JaText;
import jhplot.jadraw.JaAxes;
import jhplot.jadraw.JaKey;

import jscinttools.scint.coincidence.*;

/**
 *  Description of the Class
 *
 *@author     marc-antoine
 *@created    21 avril 2011
 */
public class PhotonCoincEffPlotter implements FigureParametersJHPlot
{
	private String title;
	private H1D spectrum;
	private F1D coincEff;



	/**
	 *  Constructor for the PhotonCoincEffPlotter object
	 *
	 *@param  spectrum  Description of the Parameter
	 *@param  title     Description of the Parameter
	 *@param  coincEff  Description of the Parameter
	 */
	public PhotonCoincEffPlotter(String title, H1D spectrum, F1D coincEff)
	{
		this.spectrum = spectrum;
		this.coincEff = coincEff;
		this.title = title;
	}


	/**
	 *  Constructor for the PhotonCoincEffPlotter object
	 */
	public PhotonCoincEffPlotter() { }


	/**
	 *  Description of the Method
	 *
	 *@param  rangeX  Description of the Parameter
	 *@return         Description of the Return Value
	 */
	public HPlotJa photonCoincEffPlotter(double[] rangeX)
	{
		HPlotJa plotter = new HPlotJa("Spectrum", 600, 600, 1, 1, true);
		plotter.setGTitle(title, titleFont);
		plotter.setAntiAlias(false);
		plotter.setPad(1, 1, 0.125, 0.125, 0.75, 0.75);
		plotter.setRange(rangeX[0], rangeX[1], 0.0, 1.1);
		plotter.setLogScale(0, false);
		plotter.setLogScale(1, false);
		plotter.setTicFont(ticFont);
		plotter.setShowStatBox(false);
		plotter.showKey(false);
		plotter.setNameX("Number of Photons");
		plotter.setNameY("Coincidence Efficiency");
		plotter.draw(spectrum);
		plotter.draw(coincEff);

		JaKey specKey = new JaKey(20, "Spectrum", 0.3, 0.3, "NDC");
		specKey.setColor(spectrum.getColor());
		specKey.setKeyColor(spectrum.getColor());
		specKey.setFont(legendFont);

		JaKey coincEffKey = new JaKey(20, "Coincidence Efficiency", 0.3, 0.35, "NDC");
		coincEffKey.setColor(coincEff.getColor());
		coincEffKey.setKeyColor(coincEff.getColor());
		coincEffKey.setFont(legendFont);

		plotter.draw(specKey);
		plotter.draw(coincEffKey);

		JaAxes theAxes_11 = plotter.getPad();
		theAxes_11.setLabelSpace(0, 0.0);
		theAxes_11.setLabelSpace(1, 0.0);
		HPlotJaUtil.setTickLabelZeroPositive(theAxes_11);

		//JaText labX = plotter.getLabelX()[0][0];
		JaText labX = plotter.getLabelsAll(0)[0][0];
		labX.setFont(axisLabelFont);
		HPlotJaUtil.setLabelLocationAtCenter(0, labX, plotter, 0.025);
		//JaText labY = plotter.getLabelY()[0][0];
		JaText labY = plotter.getLabelsAll(1)[0][0];
		labY.setFont(axisLabelFont);
		HPlotJaUtil.setLabelLocationAtCenter(1, labY, plotter, -0.01);

		plotter.update();

		return plotter;
	}


	/**
	 *  Gets the spectrum attribute of the PhotonCoincEffPlotter object
	 *
	 *@return    The spectrum value
	 */
	public H1D getSpectrum()
	{
		return spectrum;
	}


	/**
	 *  Sets the spectrum attribute of the PhotonCoincEffPlotter object
	 *
	 *@param  spectrum  The new spectrum value
	 */
	public void setSpectrum(H1D spectrum)
	{
		this.spectrum = spectrum;
	}


	/**
	 *  Gets the coincEff attribute of the PhotonCoincEffPlotter object
	 *
	 *@return    The coincEff value
	 */
	public F1D getCoincEff()
	{
		return coincEff;
	}


	/**
	 *  Sets the coincEff attribute of the PhotonCoincEffPlotter object
	 *
	 *@param  coincEff  The new coincEff value
	 */
	public void setCoincEff(F1D coincEff)
	{
		this.coincEff = coincEff;
	}


	/**
	 *  Gets the title attribute of the PhotonCoincEffPlotter object
	 *
	 *@return    The title value
	 */
	public String getTitle()
	{
		return title;
	}


	/**
	 *  Sets the title attribute of the PhotonCoincEffPlotter object
	 *
	 *@param  title  The new title value
	 */
	public void setTitle(String title)
	{
		this.title = title;
	}
}

